#!/bin/sh
#
# 功能：简单写一下脚本的功能。
#
#
#

if [ $# -ne 2 ]; then
	echo "Usage: sourceno destno"
	exit
fi

sourcedir=`ls -l |awk '{print $NF}' | grep  -w $1`

isexist=`echo $sourcedir | wc |awk '{print $2}'`

if [ $isexist -eq 0 ]; then
	echo "sourceno not exist"
	exit -1
fi

bookname=`echo $sourcedir |sed -e "s/[1234567890]//g"`

destbookname=$2$bookname

destdir=`ls -l |awk '{print $NF}' | grep  -w  $destbookname`

isexist=`echo $destdir | wc |awk '{print $2}'`

if [ $isexist -ne 0 ]; then
	echo "destno exist"
	exit -2
fi

destdir=`echo $sourcedir |sed  -e "s/$1/$destbookname/g" `

echo "from " $sourcedir  " to " $destdir

mv $sourcedir $destdir

cd $destdir 

if [ -e config ]; then
	upconfig
fi
